package com.xzzz.irda.guardcat.server;

import com.xzzz.irda.guardcat.server.alert.AlertController;
import com.xzzz.irda.guardcat.server.alert.AlertManagerInMySQL;
import com.xzzz.irda.guardcat.server.app.AppManager;
import com.xzzz.irda.guardcat.server.app.GuardcatAppController;
import com.xzzz.irda.guardcat.server.app.GuardcatAppRelationController;
import com.xzzz.irda.guardcat.server.app.GuardcatHeartbeatController;
import com.xzzz.irda.guardcat.server.metric.GuardcatMetricController;
import com.xzzz.irda.guardcat.server.metric.MetricFetchJobFactory;
import com.xzzz.irda.guardcat.server.metric.MetricFetcher;
import com.xzzz.irda.guardcat.server.metric.redis.GuardcatRedisController;
import com.xzzz.irda.guardcat.server.metric.snapshot.SnapshotRepository;
import com.xzzz.irda.guardcat.server.setting.AlertSettingManagerInMySQL;
import com.xzzz.irda.guardcat.server.setting.GuardcatSettingController;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan({"com.xzzz.irda.guardcat.server.repos.mysql.mappers"})
public class GuardcatServerConfiguration {

    @Bean
    public AppManager appManager() {
        return new AppManager();
    }

    @Bean
    public SnapshotRepository snapshotRepository() {
        return new SnapshotRepository();
    }

    @Bean
    public AlertManagerInMySQL alertManagerInMySQL() {
        return new AlertManagerInMySQL();
    }

    @Bean
    public AlertSettingManagerInMySQL alertSettingManagerInMySQL() {
        return new AlertSettingManagerInMySQL();
    }

    // fetcher

    @Bean
    public MetricFetcher metricFetcher(GuardcatServerProperties guardcatServerProperties) {
        return new MetricFetcher(guardcatServerProperties);
    }

    @Bean
    public MetricFetchJobFactory metricFetchJobFactory() {
        return new MetricFetchJobFactory();
    }

    // controller

    @Bean
    public GuardcatAppController guardcatAppController() {
        return new GuardcatAppController();
    }

    @Bean
    public GuardcatHeartbeatController guardcatHeartbeatController() {
        return new GuardcatHeartbeatController();
    }

    @Bean
    public GuardcatAppRelationController guardcatAppRelationController() {
        return new GuardcatAppRelationController();
    }

    @Bean
    public GuardcatRedisController guardcatRedisController() {
        return new GuardcatRedisController();
    }

    @Bean
    public GuardcatMetricController guardcatMetricController() {
        return new GuardcatMetricController();
    }

    @Bean
    public AlertController alertController() {
        return new AlertController();
    }

    @Bean
    public GuardcatSettingController guardcatSettingController() {
        return new GuardcatSettingController();
    }
}
